package com.zx.yixun

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.TextUtils
import android.widget.Toast
import androidx.appcompat.widget.Toolbar
import androidx.core.view.get
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.ToastUtils
import com.tencent.bugly.beta.Beta
import com.zx.yixun.ui.LoginActivity
import com.zx.yixun.util.DataStoreUtil
import com.zx.ymy.base.BaseActivity
import com.zx.ymy.net.NetWorkHelper
import com.zx.ymy.net.api.MyApi
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity :BaseActivity(){

    override fun getToolbar(): Toolbar? {
        return null
    }

    override fun getContentId(): Int {
        return R.layout.activity_main
    }

    override fun onContentCreate(savedInstanceState: Bundle?) {

        ImmersionBar(R.color.blue)
        if (DataStoreUtil.getScreenType()!=0){
            ActivityUtils.startActivity(LoginActivity::class.java)
            finish()
        }

        tv_sure.setOnClickListener {
            if (TextUtils.isEmpty(et_name.text.toString())||TextUtils.isEmpty(et_id.text.toString())){
                ToastUtils.showShort("请填写完整!")
                return@setOnClickListener
            }
            DataStoreUtil.saveScreenType(if(rb_zp.isChecked) 1 else 2)
            DataStoreUtil.saveScreenName(et_name.text.toString())
            DataStoreUtil.saveScreenId(et_id.text.toString())
            ActivityUtils.startActivity(LoginActivity::class.java)
            finish()
        }

        tv_cannel.setOnClickListener {
            finish()
        }
    }

}